package com.ruoyi.web.controller.bus.appletsController;

import com.ruoyi.bus.constant.UserTypeEnum;
import com.ruoyi.bus.service.IApiService;
import com.ruoyi.bus.vo.ChangeDriver;
import com.ruoyi.bus.vo.LoginVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Description
 * @Author caiyanshan
 * @Date 2021/7/27 8:47
 * @Param
 * @Return
 */
@Slf4j
@RestController
@RequestMapping("/dispatch")
public class DispatchApiController extends BaseController {
  
  @Autowired
  private IApiService apiService;
  
  /**
   * @Description 登录功能
   * @Author caiyanshan
   * @Date 2021/4/15 14:24
   * @Param []
   * @Return com.ruoyi.common.core.domain.AjaxResult
   */
  @PostMapping("login")
  public AjaxResult login(@Valid @RequestBody LoginVo loginVo){
    loginVo.setRegister(false);
    loginVo.setUserType(UserTypeEnum.Dispatch_User.ordinal());//调度用户
    return apiService.login(loginVo);
  }
  
  @GetMapping("todayPlanBus")
  public AjaxResult todayPlanBus(){
    return apiService.todayPlanBus();
  }
  
  @GetMapping("noPlanDriverUser")
  public AjaxResult noPlanDriverUser(){
    return apiService.noPlanDriverUser();
  }
  
  @PostMapping("changeDriver")
  public AjaxResult changeDriver(@Valid @RequestBody ChangeDriver changeDriver){
    return apiService.changeDriver(changeDriver);
  }
  
  @GetMapping("listChangeRecord")
  public AjaxResult listChangeRecord(){
    return apiService.listChangeRecord();
  }
}
